<template>
	<view class="container">
		<view class="order-tab">
			<view class="tab-item" :class="i==tab_index?'select':''" v-for="(item,i) in tabList" :key="i" @click="checkTab(i)">
				<text>{{item.text}}</text>
			</view>
		</view>
		<view class="list-box">
			<view class="item" v-for="(item,index) in list" :key="item.id">
				<view class="s-info">
					<image class="g-img" :src="$img_base_url(item.user.avatar)" mode="aspectFill"></image>
					<view class="r-text">
						<view class="name one-row">
							{{item.user.nickname}}
						</view>
						<view class="user">
							<!-- <text>服务者：张师傅</text> -->
							<text>发布于05月21日</text>
						</view>
					</view>
					
					<!-- <image class="del-icon" :src="$img_path('/pagesMine/39.png')" mode="widthFix"></image> -->
				</view>
				<view class="star">
					<image v-for="i in item.score" :key="i" :src="$img_path('/pagesMine/40.png')" mode="widthFix"></image>
				</view>
				<view class="con-text">
					{{item.content}}
				</view>
				<view class="p-img">
					<view v-for="(img,i) in item.image" :key="i" class="img-box">
						<image :src="$img_base_url(img)" @click="previewImage" mode="aspectFill"></image>
					</view>
				</view>
				<!-- <view class="cz-box">
					<text>浏览 1000</text>
					<view class="dz">
						<image v-if="false" :src="$img_path('/pagesMine/41.png')" mode="widthFix"></image>
						<image v-else :src="$img_path('/pagesMine/42.png')" mode="widthFix"></image>
						<text>100</text>
					</view>
				</view> -->
				
				<!-- <view class="huifu">
					<view class="pt" v-if="false">
						平台回复：内容内容内容内容内容内容内容内容内容内容内容内容
					</view>
					
					<view class="m-pj" v-else>
						<view class="m-star">
							<text>对我的评价：</text>
							<image v-for="item in 5" :key="item" :src="$img_path('/pagesMine/40.png')" mode="widthFix"></image>
						</view>
						<view class="text">
							内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容
						</view>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import { getServiceGoodsCommentList } from '@/utils/api/serviceApi.js'
	import { getCommentList } from '@/utils/api/mallApi.js'
	export default {
		data() {
			return {
				tabList:[
					// {
					// 	text:'全部',
					// 	value:''
					// },
					{
						text:'服务订单',
						value:'1'
					},
					{
						text:'商品订单',
						value:'2'
					}
				],
				tab_index:0,
				list:[]
			};
		},
		onLoad() {
			this.getList()
		},
		methods:{
			previewImage(urls){
				uni.previewImage({
					urls
				})
			},
			checkTab(i){
				this.tab_index = i
			},
			
			getList(){
				let id = JSON.parse(uni.getStorageSync('userInfo')).id
				if(this.tab_index==0){
					getServiceGoodsCommentList({
						page:1,
						user_id:id
					}).then(res=>{
						this.list = res.data
					})
				}
			}
			
		}
	}
</script>

<style lang="scss" scoped>
.container{
	.order-tab{
		position: sticky;
		top: 0;
		left: 0;
		right: 0;
		padding: 32rpx 22rpx 12rpx; 
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #FFFFFF;
		z-index: 3;
		.tab-item{
			&:last-child{
				margin-left: 40rpx;
			}
			text{
				font-weight: 400;
				font-size: 32rpx;
				color: #333333;
				line-height: 44rpx;
				position: relative;
			}
			&.select{
				text{
					font-weight: bold;
					font-size: 32rpx;
					color: #E72A2A;
					line-height: 44rpx;
					&::after{
						content: '';
						width: 52rpx;
						height: 8rpx;
						background: #E72A2A;
						border-radius: 4rpx;
						position: absolute;
						top: calc(100% + 4rpx);
						left: 50%;
						transform: translateX(-50%);
					}
				}
			}
		}
	}
	
	.list-box{
		padding: 0 22rpx;
		box-sizing: border-box;
		.item{
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 12rpx 2rpx rgba(223,223,223,0.16);
			border-radius: 20rpx;
			padding: 28rpx 28rpx 40rpx;
			box-sizing: border-box;
			margin-top: 20rpx;
			.s-info{
				display: flex;
				align-items: center;
				position: relative;
				.g-img{
					width: 128rpx;
					height: 128rpx;
				}
				.r-text{
					width: calc(100% - 128rpx);
					padding-left: 20rpx;
					box-sizing: border-box;
					.name{
						width: calc(100% - 60rpx);
						font-weight: bold;
						font-size: 32rpx;
						color: #333333;
						line-height: 44rpx;
					}
					.user{
						display: flex;
						justify-content: space-between;
						margin-top: 12rpx;
						text{
							font-weight: 400;
							font-size: 24rpx;
							color: #848484;
							line-height: 34rpx;
						}
					}
				}
				.del-icon{
					position: absolute;
					right: 4rpx;
					top: 0rpx;
					width: 38rpx;
					height: 43rpx;
				}
			}
			.star{
				display: flex;
				align-items: center;
				margin-top: 20rpx;
				image{
					width: 46.51rpx;
					height: 44.58rpx;
					margin-right: 18rpx;
				}
			}
			.con-text{
				font-weight: 400;
				font-size: 28rpx;
				color: #848484;
				line-height: 40rpx;
				margin-top: 46rpx;
			}
			.p-img{
				width: 100%;
				display: flex;
				flex-wrap: wrap;
				margin-top: 4rpx;
				.img-box{
					width: calc(33.33% - 13.33rpx);
					height: 0;
					padding-bottom: calc(33.33% - 13.33rpx);
					position: relative;
					margin-top: 16rpx;
					&:not(:nth-of-type(3n+1)){
						margin-left: 18rpx;
					}
					image{
						position: absolute;
						width: 100%;
						height: 100%;
						border-radius: 20rpx;
					}
				}
			}
			.cz-box{
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 20rpx;
				&>text{
					font-weight: 400;
					font-size: 28rpx;
					color: #848484;
					line-height: 40rpx;
				}
				.dz{
					display: flex;
					align-items: flex-start;
					image{
						width: 33.61rpx;
						height: 32.16rpx;
					}
					text{
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
						line-height: 40rpx;
						margin-left: 8rpx;
					}
				}
			}
			.huifu{
				padding: 16rpx 24rpx;
				box-sizing: border-box;
				margin-top: 20rpx;
				background: #EEEEEE;
				border-radius: 16rpx;
				.pt{
					font-weight: 400;
					font-size: 28rpx;
					color: #484848;
					line-height: 40rpx;
				}
				
				.m-pj{
					.m-star{
						display: flex;
						align-items: center;
						text{
							font-weight: 400;
							font-size: 28rpx;
							color: #484848;
							line-height: 40rpx;
						}
						image{
							width: 29.33rpx;
							height: 28.12rpx;
							margin-right: 10rpx;
						}
					}
					.text{
						font-weight: 400;
						font-size: 28rpx;
						color: #484848;
						line-height: 40rpx;
						margin-top: 12rpx;
					}
				}
			}
		}
	}
	
}
</style>
